#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>

int main(int argc, char const *argv[])
{
    FILE * test_file =  fopen("testfile.txt","a");

    int temp_result =  setvbuf(test_file,NULL,_IOFBF,0);
    if (temp_result < 0)
    {
        perror("setvbuf");
        return 1;
    }

    fputs("hello",test_file);
    fflush(test_file);
    char *arg[] = {"/usr/bin/ping","-c","1","www.atguigu.com",NULL};
    char *env[] = {NULL};
    execve("/usr/bin/ping",arg,env);
    perror("execve");

    return 0;
}
